#include "lightScene.h"

LightScene::LightScene()
{
	if (nullptr == m_Camera)
	{
		m_Camera = new Camera3D();
	}

	if (nullptr == m_RootObj)
	{
		m_RootObj = new SceneObj(nullptr, nullptr, "Root Obj");
		if (nullptr == m_SelectedObj)
		{
			m_SelectedObj = new SceneObj(nullptr, new SW::LightSprite(), "LightSprite");
		}
		m_RootObj->PushChild(m_SelectedObj);
	}
}

LightScene::~LightScene()
{
	if (m_Camera)
	{
		delete m_Camera;
		m_Camera = nullptr;
	}

	if (m_RootObj)
	{
		delete m_RootObj;
		m_RootObj = nullptr;
	}
}

void LightScene::Update(float deltaTime)
{
	if (m_Camera)
	{
		m_Camera->Update(deltaTime);
	}	
}

void LightScene::Render()
{
	SW::Renderer::SetCurrentCamera(m_Camera);

	if (m_RootObj)
	{
		m_RootObj->Render();
	}
}

void LightScene::RenderSwGui()
{
	SW::Begin("options");

	if (SW::ArrowButton("AddLight", SwGuiDir_Up))
	{		
		int curPointlightNum = ((LightSprite*)m_SelectedObj->GetSprite())->GetPointlightNumber();
		((LightSprite*)m_SelectedObj->GetSprite())->AddPointlight("pointLight");
	}
	

	SW::End();
}